<?php

namespace App\Exports\Cruise;

use App\Models\Cruise\CruiseCheckCompanyModel;
use App\Models\Cruise\CruiseCheckTaskGroupModel;
use App\Models\Cruise\CruiseCheckTaskModel;
use App\Remote\Rms\RmsShopRemote;
use App\Remote\Rms\RmsUserRemote;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\FromCollection;

class ShopLicenseExport implements FromArray
{
    public $originalData;
    public $excelHeaders;
    public $excelContents = [];

    public function __construct($list)
    {
        $this->originalData = $list;
    }

    public function array(): array
    {
        $this->generateExcelHeader();
        collect($this->originalData)->map(function ($item) {

            $this->excelContents[] = [
                $item['shopCode'],
                $item['name'],
                $item['shopStatus'],
                $item['addressPrefix'],
                $item['councilorName'],
                $item['status'],
                $item['businessLicenseStatus'],
                $item['foodLicenseStatus'],
                $item['mainBusiness'],
                $item['businessScope'],
                $item['merchantUpdatedAt'],
                $item['cruiseAt'],
            ];


        })->values()->toArray();

        return collect(
            [$this->excelHeaders]
        )->merge($this->excelContents)->toArray();
    }


    public function generateExcelHeader()
    {
        $this->excelHeaders = [
            "门店编号",
            "门店名称",
            "门店状态",
            "所属区域",
            "门店督导",
            "备案状态",
            "营业执照",
            "食品经营许可证",
            "主体业态",
            "经营项目",
            "商家最近操作",
            "最近审核时间",
        ];
    }
}
